package cn.gson.springmvc.model.pojos;

import javax.persistence.*;
import java.math.BigDecimal;
import java.sql.Timestamp;
import java.util.Collection;
import java.util.Objects;

@Entity
public class Medical {
    private int medicalId;
    private Timestamp medicalDate;
    private String medicalName;
    private String medicalCard;
    private String medicalType;
    private BigDecimal medicalMoney;
    private BigDecimal medicalBalance8;
    private Integer medicalPass;
    private String medicalState;
    private Patient patientByPatientId;
    private Collection<Payment> paymentsByMedicalId;
    private Collection<Veg> vegsByMedicalId;

    @Id
    @Column(name = "medical_id", nullable = false)
    public int getMedicalId() {
        return medicalId;
    }

    public void setMedicalId(int medicalId) {
        this.medicalId = medicalId;
    }

    @Basic
    @Column(name = "medical_date", nullable = true)
    public Timestamp getMedicalDate() {
        return medicalDate;
    }

    public void setMedicalDate(Timestamp medicalDate) {
        this.medicalDate = medicalDate;
    }

    @Basic
    @Column(name = "medical_name", nullable = true, length = 20)
    public String getMedicalName() {
        return medicalName;
    }

    public void setMedicalName(String medicalName) {
        this.medicalName = medicalName;
    }

    @Basic
    @Column(name = "medical_card", nullable = true, length = 20)
    public String getMedicalCard() {
        return medicalCard;
    }

    public void setMedicalCard(String medicalCard) {
        this.medicalCard = medicalCard;
    }

    @Basic
    @Column(name = "medical_type", nullable = true, length = 20)
    public String getMedicalType() {
        return medicalType;
    }

    public void setMedicalType(String medicalType) {
        this.medicalType = medicalType;
    }

    @Basic
    @Column(name = "medical_money", nullable = true, precision = 2)
    public BigDecimal getMedicalMoney() {
        return medicalMoney;
    }

    public void setMedicalMoney(BigDecimal medicalMoney) {
        this.medicalMoney = medicalMoney;
    }

    @Basic
    @Column(name = "medical_balance8", nullable = true, precision = 2)
    public BigDecimal getMedicalBalance8() {
        return medicalBalance8;
    }

    public void setMedicalBalance8(BigDecimal medicalBalance8) {
        this.medicalBalance8 = medicalBalance8;
    }

    @Basic
    @Column(name = "medical_pass", nullable = true, precision = 0)
    public Integer getMedicalPass() {
        return medicalPass;
    }

    public void setMedicalPass(Integer medicalPass) {
        this.medicalPass = medicalPass;
    }

    @Basic
    @Column(name = "medical_state", nullable = true, length = 2)
    public String getMedicalState() {
        return medicalState;
    }

    public void setMedicalState(String medicalState) {
        this.medicalState = medicalState;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Medical medical = (Medical) o;
        return medicalId == medical.medicalId &&
                Objects.equals(medicalDate, medical.medicalDate) &&
                Objects.equals(medicalName, medical.medicalName) &&
                Objects.equals(medicalCard, medical.medicalCard) &&
                Objects.equals(medicalType, medical.medicalType) &&
                Objects.equals(medicalMoney, medical.medicalMoney) &&
                Objects.equals(medicalBalance8, medical.medicalBalance8) &&
                Objects.equals(medicalPass, medical.medicalPass) &&
                Objects.equals(medicalState, medical.medicalState);
    }

    @Override
    public int hashCode() {
        return Objects.hash(medicalId, medicalDate, medicalName, medicalCard, medicalType, medicalMoney, medicalBalance8, medicalPass, medicalState);
    }

    @ManyToOne
    @JoinColumn(name = "patient_id", referencedColumnName = "patient_id")
    public Patient getPatientByPatientId() {
        return patientByPatientId;
    }

    public void setPatientByPatientId(Patient patientByPatientId) {
        this.patientByPatientId = patientByPatientId;
    }

    @OneToMany(mappedBy = "medicalByMedicalId")
    public Collection<Payment> getPaymentsByMedicalId() {
        return paymentsByMedicalId;
    }

    public void setPaymentsByMedicalId(Collection<Payment> paymentsByMedicalId) {
        this.paymentsByMedicalId = paymentsByMedicalId;
    }

    @OneToMany(mappedBy = "medicalByMedicalId")
    public Collection<Veg> getVegsByMedicalId() {
        return vegsByMedicalId;
    }

    public void setVegsByMedicalId(Collection<Veg> vegsByMedicalId) {
        this.vegsByMedicalId = vegsByMedicalId;
    }
}